<template>
  <ElSubmenu v-if="data.children" :key="'submenu' + data.id">
    <template slot="title">{{ data.title }}</template>
    <template v-for="child in data.children">
      <Resub :key="child.id" :data="child"></Resub>
    </template>
  </ElSubmenu>
  <ElMenuItem v-else :key="'menu' + data.id">
    {{ data.title }}
  </ElMenuItem>
</template>

<script>
import ElSubmenu from './ElSubmenu.vue'
import ElMenuItem from './ElMenuItem.vue'
export default {
  // 可以根据组件的名称 调用自己
  name: 'Resub',
  props: {
    data: {
      type: Object
    }
  },
  components: { ElSubmenu, ElMenuItem }
}
</script>

<style lang="scss" scoped></style>
